﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BO.News;

namespace GUI.Controls.Sport
{
    public partial class BoxBangXepHang : System.Web.UI.UserControl
    {
        private const string format0 = "<li class=\"tab-header\"><a href=\"javascript:void(0);\">{0}</a></li>";
        private const string tableheader =
            "<table class='tab-content'><tr><th>TT</th><th>Đội</th><th>Trận</th><th>HS</th><th>Điểm</th></tr>";


        private const string format1 = "<tr><td><span>{0}</span></td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td></tr>";
        protected void Page_Load(object sender, EventArgs e)
        {
            var data = NewsBO.GetBangXepHang();
            if (data != null && data.Any())
            {
                var sb = new StringBuilder();
                foreach (var r in data)
                {
                    switch (r.CountryName.ToLower())
                    {
                        case "ý":
                            {
                                r.CountryName = "Italia";
                                break;
                            }
                        case "tây ban nha":
                            {
                                r.CountryName = "TBN";
                                break;
                            }
                        default:
                            {
                                break;
                            }
                    }
                    ltrTabHeader.Text += string.Format(format0, r.CountryName);
                    sb.Append(tableheader);
                    foreach (var ri in r.Items)
                    {
                        sb.AppendFormat(format1, ri.Rank, ri.TeamName, ri.MatchCount, ri.Offset, ri.Points);
                    }
                    sb.Append("</table>");
                }
                this.ltrData.Text = sb.ToString();
            }
        }
    }
}